﻿using System;

namespace mg_test
{
    class Game:Microsoft.Xna.Framework.Game
    {
        Microsoft.Xna.Framework.Graphics.SpriteBatch batcher;
        Microsoft.Xna.Framework.Graphics.Texture2D texWhite;
        public Game()
        {
            this.Window.AllowUserResizing = true;

            IsMouseVisible = true;
        }
        protected override void LoadContent()
        {
            IMGUI_Light.GUI.Init(new IMGUI_Light.Adapter.XnaAdp(this));
            texWhite = new Microsoft.Xna.Framework.Graphics.Texture2D(GraphicsDevice, 2, 2,false,Microsoft.Xna.Framework.Graphics.SurfaceFormat.Color);
            var data = new UInt32[4];
            for (var i = 0; i < 4; i++)
                data[i] = 0xffffffff;
            texWhite.SetData(data);
          
            batcher = new Microsoft.Xna.Framework.Graphics.SpriteBatch(GraphicsDevice);
            base.LoadContent();
        }
        protected override void Update(Microsoft.Xna.Framework.GameTime gameTime)
        {
            base.Update(gameTime);
        }
        protected override void Draw(Microsoft.Xna.Framework.GameTime gameTime)
        {
            GraphicsDevice.Clear(Microsoft.Xna.Framework.Color.CornflowerBlue);

            batcher.Begin(Microsoft.Xna.Framework.Graphics.SpriteSortMode.Immediate);
            batcher.Draw(texWhite, new Microsoft.Xna.Framework.Rectangle(0, 0, 100, 100), Microsoft.Xna.Framework.Color.IndianRed);
            batcher.End();
            base.Draw(gameTime);
        }
    }
    class Program
    {
        public static bool exit = false;
        static void Main(string[] args)
        {
            Console.WriteLine("this is a tool powered by monogame.");

            System.Threading.Thread threadWin = new System.Threading.Thread(() =>
             {
                 //不支持多窗口，无所谓
                 Microsoft.Xna.Framework.GraphicsDeviceManager graphicmanager;

                 using (var game = new Game())
                 {
                     //必须要new一个设备管理器
                     graphicmanager = new Microsoft.Xna.Framework.GraphicsDeviceManager(game);

                     game.Run();
                 }
             });
            threadWin.IsBackground = true;
            threadWin.Start();
            while(!exit)
            {
                Console.ReadLine();
            }
        }
    }
}
